<template>
	<view class="">
		<view class="mainpadding radius " style="background-color: #c1282e;">
			<view class="flexcolumn">
				<view class="xiaobai titletext bold">钱包余额</view>
				<view class="xiaobai margin_top bold" style="font-size: 40rpx;">{{userInfo.money}}</view>
				<view class="baibtn xiaobai margin_top" @click="jumpurl('/pages/tab4/tixian')">提现</view>
			</view>
		</view>
		<view class="mainpadding" v-if="list.data.length">
			<view class="titletext fonweight zhonghei" >钱包余额明细</view>
			<view class="mainpadding ffffff radius margin_top">
				<view class="shangbj flexbetween  xiahuaxian" :class="index!=0?'margin_top':''" v-for="(item,index) in list.data" :key="item.id">
					<view class="">
						<view class="ershiba fonweight zhonghei">{{item.memo}}</view>
						<view class="strongtext margin_top1 xiaohui">{{item.createtime_text}}</view>
					</view>
					<view class="flexright">
						<view class="sanshier fonweight xiaocheng">{{item.money}}</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				userInfo:{},
				page: 1,
				limit: 12,
				list: {
					data: []
				},
			}
		},
		onShow() {
			this.userinfomsg()
			this.init()
		},
		methods: {
			userinfomsg() {
				httpRequest.request('/api/user/getUerInfo', 'GET', {}).then(res => {
					this.userInfo = res.data
				})
			},
			init(isPage, page) {
				let _this = this
				let url = "/api/user/moneyLog"
				let data = {
					page: page || 1,
					limit: _this.limit,
				}
				httpRequest.request(url, 'GET', data, false, false, true).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
						}
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
			jumpurl(url){
				uni.navigateTo({
					url
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
.baibtn {
		width: 194rpx;
		height: 65rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		border-radius: 10rpx;
		border: 2rpx solid #FFFFFF;
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #fff;
	}
	.topcontent {
		padding: 30rpx 40rpx;
		background: rgba(255, 255, 255, 0.2);
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		border: 1rpx solid rgba(255, 255, 255, 0.6);
	}
	
	.myline {
		width: 1rpx;
		height: 40rpx;
		background-color: rgba(255, 255, 255, 0.4);
	}
</style>
